package issr.market.controller;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;

import com.opensymphony.xwork2.ModelDriven;

public abstract class AbstractController implements
		ServletRequestAware, ServletResponseAware, ModelDriven<Object>, Serializable{
	
/**
	 * 
	 */
	private static final long serialVersionUID = 5774965463291652768L;
	
	private HttpServletRequest request;
	private HttpServletResponse response;
	private String actionToDo;
	
	
	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}
	public HttpServletResponse getServletResponse(){
		return response;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}
	public HttpServletRequest getServletRequest(){
		return request;
	}
	
	public String getParameter(String paramName){
		return request.getParameter(paramName);
	}
	
	public String[] getParameters(String paramName){
		return request.getParameterValues(paramName);
	}


	public String getActionToDo() {
		return actionToDo;
	}


	public void setActionToDo(String actionToDo) {
		this.actionToDo = actionToDo;
	}
	
	@Override
	public Object getModel() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public HttpHeaders index(){
		return new DefaultHttpHeaders("view").disableCaching();
	}
	
	protected boolean accessForbidden(){
		
		return request.getSession().getAttribute("userLogged")==null;
	}


}
